import React from 'react'
// ===================================================================== global declare
const { $Lazy, $http, $fn } = window
// ===================================================================== Lazy
// const $cache 			= $Lazy.file(()=>import('#private/cache-api'))
// const Header			= $Lazy.hook(()=>import('./header'))
// const Button 			= $Lazy.load(()=>import('@antd/button'))
// const DatePicker 		= $Lazy.load(()=>import('@antd/form/datePicker'))
// const Checkbox	 		= $Lazy.load(()=>import('@antd/form/checkbox'))
const CheckboxGroup 	= $Lazy.load(()=>import('@antd/form/checkboxGroup'))
const Echart 			= $Lazy.state(()=>import('../modal/lj-cpt/chart'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		levels: [],
		levelsData: [],
		info:{}
	}
	
	componentDidMount(){
		this.info()
	}
	
	info = () => {
		const { uuid } = this.props.thisRef.cRow
		$http.pull(null, 'qc-test/info', {param:{uuid}}).then(data => {
			const ldata = []
			if ($fn.hasArray(data.levels)) {
				data.levels.forEach(v => ldata.push({name: v}))
			}
			this.echartRef.refs.ref.init()
			this.setState({info: data, levelsData: ldata, levels: data.levels})
		})
	}
	
	render(){
		const { info, levels, levelsData } = this.state
		return <div className='fv wh'>
			<div className='fxm plr10 lh40'>
				{/*<div className='mr15'>
					<span>日期：</span>
					<DatePicker range showTime />
				</div>
				<Button style={{padding: '0 2px', marginRight: 2}} label='<' />
				<Button style={{padding: '0 2px', marginRight: 15}} label='>' />
				<div>
					<span>应用到所有：</span>
					<Checkbox />
				</div>*/}
				<div className='mr15'>
					<span className='b' style={{width: 70}}>测试：</span>
					<span>{info?.analyte_name}</span>
				</div>
				<div>
					<span>水平：</span>
					<CheckboxGroup value={levels} onChanged={ ({value}) => this.setState({levels: value}) } label='水平' idStr='name' data={levelsData} />
				</div>
			</div>
			<Echart ref={ref => this.echartRef = ref} levels={levels} thisRef={this.props.thisRef} />
		</div>
	}
}

export default Index